package myplugin;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

class definitionWindow extends JFrame {
    JLabel defnamespace;
    JTextField defNamespaceTextfield;
    JButton defNext;
    JLabel defLocation;
    JTextField defLocationTextField;
    JButton defAdd;
    String namespace;
    String location;
	ArrayList<String> anamespace = new ArrayList<String>();
	ArrayList<String> alocation = new ArrayList<String>();
	
	
    

    public definitionWindow() {
        definitionWindowLayout customLayout = new definitionWindowLayout();

        setFont(new Font("Helvetica", Font.PLAIN, 12));
        setLayout(customLayout);

        defnamespace = new JLabel("Namepace:");
        add(defnamespace);

        defNamespaceTextfield = new JTextField("<insert namespace link here e.g.: xmlns:xsd>");
        add(defNamespaceTextfield);

        defNext = new JButton("Next");
        add(defNext);

        defLocation = new JLabel("Location");
        add(defLocation);

        defLocationTextField = new JTextField("<insert location link here e.g.:http://www.w3.org/2001/XMLSchema>");
        add(defLocationTextField);

        defAdd = new JButton("Add definition");
        add(defAdd);

        setSize(getPreferredSize());

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                //System.exit(0);
            }
        });
		defNext.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				defnextActionPerformed(evt);
			}
			private void defnextActionPerformed(ActionEvent evt) {
				//if the next button is pushed, we create the next JFRAME and then dispose this
		        ns window = new ns();
		        
		        window.setTitle("Import Window");
		        window.pack();
		        window.setBnamespace(anamespace);
		        window.setBlocation(alocation);
		        window.show();
		        dispose();
			};
		});
		defAdd.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				defActionPerformed(evt);
			}

			private void defActionPerformed(ActionEvent evt) {
				// reads out the Strings from the TextFields and add them to the namespace and location attributums
				String namespace = defNamespaceTextfield.getText();
				String location = defLocationTextField.getText();

				anamespace.add(namespace);
				alocation.add(location);
			}});
		

	    } 


    public String getNamespace()
    {
    	return namespace;
    }
    public String getnsLocation(){
    	return location;
    }


		}